home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / LOTTYPES.C < prev    next >
Text File  |  1989-12-30  |  2KB  |  38 lines

  1. main()
  2. {
  3. int a;              /* simple integer type             */
  4. long int b;         /* long integer type               */
  5. short int c;        /* short integer type              */
  6. unsigned int d;     /* unsigned integer type           */
  7. char e;             /* character type                  */
  8. float f;            /* floating point type             */
  9. double g;           /* double precision floating point */
  10.  
  11.    a = 1023; 
  12.    b = 2222;
  13.    c = 123;
  14.    d = 1234;
  15.    e = 'X';
  16.    f = 3.14159;
  17.    g = 3.1415926535898;
  18.  
  19.    printf("a = %d\n",a);      /* decimal output        */
  20.    printf("a = %o\n",a);      /* octal output          */
  21.    printf("a = %x\n",a);      /* hexadecimal output    */
  22.    printf("b = %ld\n",b);     /* decimal long output   */
  23.    printf("c = %d\n",c);      /* decimal short output  */
  24.    printf("d = %u\n",d);      /* unsigned output       */
  25.    printf("e = %c\n",e);      /* character output      */
  26.    printf("f = %f\n",f);      /* floating output       */
  27.    printf("g = %f\n",g);      /* double float output   */
  28.    printf("\n");
  29.    printf("a = %d\n",a);      /* simple int output          */
  30.    printf("a = %7d\n",a);     /* use a field width of 7     */
  31.    printf("a = %-7d\n",a);    /* left justify in field of 7 */
  32.    printf("\n");
  33.    printf("f = %f\n",f);      /* simple float output   */
  34.    printf("f = %12f\n",f);    /* use field width of 12 */
  35.    printf("f = %12.3f\n",f);  /* use 3 decimal places  */
  36.    printf("f = %12.5f\n",f);  /* use 5 decimal places  */ 
  37.    printf("f = %-12.5f\n",f); /* left justify in field */
  38. }